<?php
class Person
{
    /**
     * @var Html
     */
    private $_html;
    private $id = 0;
    private $lastName = '';
    private $firstNames = '';
    private $formerName = '';
    private $neeName = '';
    private $alsoKnownAs = '';
    private $deathDate = '';
    private $birthDate = '';
    private $age = '';
    private $ageMeasure = '';
    private $cityTown = '';
    private $formerCityTown = '';
    private $region = '';
    private $country = '';
    private $charity = '';
    private $funeralHome = '';
    private $otherInfo = '';
    /**
     * @return void
     * @param Html $html
     */
    function __construct($html)
    {
        $this->_html = $html;
    }
    /**
     * @return bool
     * @param array[string]string $person
     */
    function set($person)
    {
        $this->id = intval($person['ID']);
        $this->lastName = $person['Surname'];
        $this->firstNames = $person['FirstNames'];
        $this->formerName = $person['FormerName'];
        $this->neeName = $person['NeeName'];
        $this->alsoKnownAs = $person['AlsoKnownAs'];
        $this->deathDate = $person['DeathDate'];
        $this->birthDate = $person['BirthDate'];
        $this->age = $person['Age'];
        $this->ageMeasure = $person['AgeMeasure'];
        $this->cityTown = $person['CityTown'];
        $this->formerCityTown = $person['FormerCityTown'];
        $this->region = $person['Region'];
        $this->country = $person['Country'];
        $this->charity = $person['Charity'];
        $this->funeralHome = $person['FuneralHome'];
        $this->otherInfo = $person['OtherInfo'];
        return TRUE;
    }
    /**
     * @return string
     * @param string $tagName
     * @param string $value
     */
    private function xmlTag($tagName, $value)
    {
        return <<< EOT
        <$tagName>$value</$tagName>

EOT;
    }
    /**
     * @return string
     */
    function toXML()
    {
        $html = $this->_html;
        $tags = '';
        foreach (array(
            'value' => strval($this->id),
            'surname' => $this->lastName,
            'firstnames' => $this->firstNames,
            'formername' => $this->formerName,
            'neename' => $this->neeName,
            'alsoknownas' => $this->alsoKnownAs,
            'deathdate' => $this->deathDate,
            'birthdate' => $this->birthDate,
            'age' => $this->age,
            'agemeasure' => $this->ageMeasure,
            'citytown' => $this->cityTown,
            'formercitytown' => $this->formerCityTown,
            'region' => $this->region,
            'country' => $this->country,
            'charity' => $this->charity,
            'funeralhome' => $this->funeralHome,
            'otherinfo' => $this->otherInfo
        ) as $tag => $value) {
            $value = $html->text($value);
            $tags .= $this->xmlTag($tag, $value);
        }
        return <<< EOT
    <item>
$tags    </item>

EOT;
    }
}
?>